package com.github.gexiao.middleware.ratelimiter.annotation;

import com.github.gexiao.middleware.ratelimiter.service.impl.DefaultRateLimiterHandler;

import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

/**
 * 限流注解
 */
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.METHOD)
public @interface DoRateLimiter {
    /**
     * 每秒限流数
     *
     * @return
     */
    double permitsPerSecond() default 0;

    /**
     * 返回消息
     *
     * @return
     */
    String msg() default "达到限流阈值";

    Class<?> rateLimiterHandler() default DefaultRateLimiterHandler.class;
}
